home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / TXT / MASMBUGS.TXT < prev    next >
Text File  |  1996-11-18  |  2KB  |  46 lines

  1. MASM Bugs & how to overcome them...
  2. -----------------------------------
  3.  
  4.         MASM V6.11 was created mainly for 16bit appz like DOS and Windows 3.1
  5. They never tested 32bit compiling enough.  I've talk to Microsoft about
  6. it a lot and it seems they never knew but assured me all 32bit bugs would
  7. soon be eliminated due to Windows 95 usage.  Anyways here's what you have to
  8. avoid and how to get around it.
  9.  
  10.         All the bugs are around the INVOKE command which calls a proc in C
  11. style.  Here is an example of the problems
  12.  
  13. demo proc,a:dword
  14.   mov eax,a
  15.   ret
  16. demo endp
  17.  
  18. invoke demo,bx
  19.  
  20. When the above is completed MASM will expand bx to a 32bit register by pushing
  21. a 16bit 0 and then BX.  But they forget to put a db66h somewhere so they push
  22. a 32bit 0 instead and this messes everything up causing great headaches with
  23. a lot of fustrating debugging and start to really piss you off BIG TIME!!!!!
  24. It also assumes that segment registers when pushed are 16bit and they are not
  25. in PMODE.  When pushing seg regs in PMODE the CPU pushes a dword not a word.
  26. Just for alignment purposes.  Note that invoke dword aligns all parameters
  27. regardless whether the wanted variable is a byte or word.  It just does not
  28. do it properly in some cases.
  29.   case 1-if a dword is expected but a word is given then it messes up
  30.          NOTE: varargs are all considered dwords
  31.   case 2-segment registers are assumed 16bit when pushed
  32.  
  33.  
  34.         What I have done is made a macro called 'callp' which does exactly
  35. what invoke does but it works.  So use callp instead of invoke!!!!
  36.  Probs with callp: it does not check for parameter matching, it simply just
  37.    pushes everything as a dword.  It may be a little slower but not by
  38.    much and it is worth it...(it uses movzx eax,var a lot so you can't pass
  39.    eax to proc unless it's the first one to be pushed, the one on the right)
  40.    It will let you know when you used EAX when you were not allowed.
  41.    As long as a movzx was not needed you can use it.
  42.     eg: callp printf,eax,ebx,ecx,edx   ;that's OK
  43.         callp printf,eax,bx,cl         ;ERROR!!
  44.  
  45. see pasm.txt for more info
  46.